<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Crafty - Crafty.math.Matrix2D</title>
	<link type="text/css" rel="stylesheet" href="/craftyjs-site.css" />

	<link href='http://fonts.googleapis.com/css?family=Arvo:regular,bold' rel='stylesheet' 	type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
	<link rel="shortcut icon" href="/favicon.ico">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
	<link rel="stylesheet" href="/github.css"/>
	<script type="text/javascript">

		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-23935213-2']);
		_gaq.push(['_trackPageview']);

		(function () {
			var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		})();

	</script>
</head>
<body>
	<div id = "header-background"> </div>
	<div id = "page-frame">
	<div id="header">
		<nav class="navbar">
  			<div class="container-fluid">
  				<div class="navbar-header">
  					<a class="navbar-brand" href="/"> <img class="logo" src="/images/text-logo.png" /> </a>
  					
				</div>
				<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
					<ul class="nav navbar-nav">
						<li><a href="/">Home</a></li>
						<li><a href="/getting-started/">Getting started</a></li>
						<li><a href="/documentation/">Documentation</a></li>
						<li><a href="/api/">API</a></li>
						<li><a href="https://groups.google.com/forum/#!forum/craftyjs">Forum</a></li>
						<li><a href="/components/">Components</a></li>
						<li class="emph"><a href="/#install">Download</a></li>
					</ul>
				</div>
			</div>
		</nav>
	</div>


	<div id="main">
		<div id="content" class="container">
			



<div id="docs"><div class="toc-holder" id="doc-nav"><ul id="doc-level-one"><li><a href="events.html">List of Events</a></li><li class="category">Core<ul class="category-list"><li><a href="Crafty.html">Crafty</a></li><li><a href="Crafty Core.html">Crafty Core</a></li><li><a href="Crafty-bind.html">Crafty.bind()</a></li><li><a href="Crafty-c.html">Crafty.c()</a></li><li><a href="Crafty-clone.html">Crafty.clone()</a></li><li><a href="Crafty-defineField.html">Crafty.defineField()</a></li><li><a href="Crafty-e.html">Crafty.e()</a></li><li><a href="Crafty-extend.html">Crafty.extend()</a></li><li><a href="Crafty-frame.html">Crafty.frame()</a></li><li><a href="Crafty-getVersion.html">Crafty.getVersion()</a></li><li><a href="Crafty-init.html">Crafty.init()</a></li><li><a href="Crafty-isPaused.html">Crafty.isPaused()</a></li><li><a href="Crafty-one.html">Crafty.one()</a></li><li><a href="Crafty-pause.html">Crafty.pause()</a></li><li><a href="Crafty-s.html">Crafty.s()</a></li><li><a href="Crafty-settings.html">Crafty.settings</a></li><li><a href="Crafty-stage.html">Crafty.stage</a></li><li><a href="Crafty-stop.html">Crafty.stop()</a></li><li><a href="Crafty-support.html">Crafty.support</a></li><li><a href="Crafty-trigger.html">Crafty.trigger()</a></li><li><a href="Crafty-unbind.html">Crafty.unbind()</a></li><li><a href="Crafty-uniqueBind.html">Crafty.uniqueBind()</a></li></ul></li><li class="category">2D<ul class="category-list"><li><a href="2D.html">2D</a></li><li><a href="AngularMotion.html">AngularMotion</a></li><li><a href="Collision.html">Collision</a></li><li><a href="Crafty-circle.html">Crafty.circle</a></li><li><a href="Crafty-diamondIso.html">Crafty.diamondIso</a></li><li><a href="Crafty-HashMap.html">Crafty.HashMap</a></li><li><a href="Crafty-isometric.html">Crafty.isometric</a></li><li><a href="Crafty-map.html">Crafty.map</a></li><li><a href="Crafty-math-Matrix2D.html">Crafty.math.Matrix2D</a></li><li><a href="Crafty-math-Vector2D.html">Crafty.math.Vector2D</a></li><li><a href="Crafty-polygon.html">Crafty.polygon</a></li><li><a href="Crafty-raycast.html">Crafty.raycast()</a></li><li><a href="Crafty-rectManager.html">Crafty.rectManager</a></li><li><a href="Gravity.html">Gravity</a></li><li><a href="GroundAttacher.html">GroundAttacher</a></li><li><a href="Motion.html">Motion</a></li><li><a href="Supportable.html">Supportable</a></li></ul></li><li class="category">Animation<ul class="category-list"><li><a href="Crafty-easing.html">Crafty.easing</a></li><li><a href="SpriteAnimation.html">SpriteAnimation</a></li><li><a href="Tween.html">Tween</a></li></ul></li><li class="category">Assets<ul class="category-list"><li><a href="Crafty-asset.html">Crafty.asset()</a></li><li><a href="Crafty-assets.html">Crafty.assets</a></li><li><a href="Crafty-imageWhitelist.html">Crafty.imageWhitelist()</a></li><li><a href="Crafty-load.html">Crafty.load()</a></li><li><a href="Crafty-paths.html">Crafty.paths()</a></li><li><a href="Crafty-removeAssets.html">Crafty.removeAssets()</a></li></ul></li><li class="category">Audio<ul class="category-list"><li><a href="Crafty-audio.html">Crafty.audio</a></li></ul></li><li class="category">Controls<ul class="category-list"><li><a href="Controllable.html">Controllable</a></li><li><a href="Controls.html">Controls</a></li><li><a href="Draggable.html">Draggable</a></li><li><a href="Fourway.html">Fourway</a></li><li><a href="Jumper.html">Jumper</a></li><li><a href="Multiway.html">Multiway</a></li><li><a href="Twoway.html">Twoway</a></li></ul></li><li class="category">Debug<ul class="category-list"><li><a href="Crafty-error.html">Crafty.error()</a></li><li><a href="Crafty-log.html">Crafty.log()</a></li><li><a href="DebugCanvas.html">DebugCanvas</a></li><li><a href="DebugPolygon.html">DebugPolygon</a></li><li><a href="DebugRectangle.html">DebugRectangle</a></li><li><a href="SolidAreaMap.html">SolidAreaMap</a></li><li><a href="SolidHitBox.html">SolidHitBox</a></li><li><a href="VisibleMBR.html">VisibleMBR</a></li><li><a href="WiredAreaMap.html">WiredAreaMap</a></li><li><a href="WiredHitBox.html">WiredHitBox</a></li></ul></li><li class="category">Events<ul class="category-list"><li><a href="Crafty-addEvent.html">Crafty.addEvent()</a></li><li><a href="Crafty-bind.html">Crafty.bind()</a></li><li><a href="Crafty-one.html">Crafty.one()</a></li><li><a href="Crafty-removeEvent.html">Crafty.removeEvent()</a></li><li><a href="Crafty-trigger.html">Crafty.trigger()</a></li><li><a href="Crafty-unbind.html">Crafty.unbind()</a></li><li><a href="Crafty-uniqueBind.html">Crafty.uniqueBind()</a></li></ul></li><li class="category">Game Loop<ul class="category-list"><li><a href="Crafty-timer.html">Crafty.timer</a></li></ul></li><li class="category">Graphics<ul class="category-list"><li><a href="Canvas.html">Canvas</a></li><li><a href="CanvasLayer.html">CanvasLayer</a></li><li><a href="Color.html">Color</a></li><li><a href="Crafty-assignColor.html">Crafty.assignColor()</a></li><li><a href="Crafty-background.html">Crafty.background()</a></li><li><a href="Crafty-createLayer.html">Crafty.createLayer()</a></li><li><a href="Crafty-defaultShader.html">Crafty.defaultShader()</a></li><li><a href="Crafty-domHelper.html">Crafty.domHelper</a></li><li><a href="Crafty-pixelart.html">Crafty.pixelart()</a></li><li><a href="Crafty-sprite.html">Crafty.sprite()</a></li><li><a href="Crafty-WebGLShader.html">Crafty.WebGLShader()</a></li><li><a href="DOM.html">DOM</a></li><li><a href="DomLayer.html">DomLayer</a></li><li><a href="HTML.html">HTML</a></li><li><a href="Image.html">Image</a></li><li><a href="Particles.html">Particles</a></li><li><a href="Renderable.html">Renderable</a></li><li><a href="Sprite.html">Sprite</a></li><li><a href="Text.html">Text</a></li><li><a href="WebGL.html">WebGL</a></li><li><a href="WebGLLayer.html">WebGLLayer</a></li></ul></li><li class="category">Input<ul class="category-list"><li><a href="AreaMap.html">AreaMap</a></li><li><a href="Button.html">Button</a></li><li><a href="Crafty-findPointerEventTargetByComponent.html">Crafty.findPointerEventTargetByComponent()</a></li><li><a href="Crafty-keyboardDispatch.html">Crafty.keyboardDispatch()</a></li><li><a href="Crafty-keydown.html">Crafty.keydown</a></li><li><a href="Crafty-keys.html">Crafty.keys</a></li><li><a href="Crafty-lastEvent.html">Crafty.lastEvent</a></li><li><a href="Crafty-mouseButtons.html">Crafty.mouseButtons</a></li><li><a href="Crafty-mouseDispatch.html">Crafty.mouseDispatch()</a></li><li><a href="Crafty-mouseWheelDispatch.html">Crafty.mouseWheelDispatch()</a></li><li><a href="Crafty-multitouch.html">Crafty.multitouch()</a></li><li><a href="Crafty-selected.html">Crafty.selected</a></li><li><a href="Crafty-touchDispatch.html">Crafty.touchDispatch()</a></li><li><a href="Keyboard.html">Keyboard</a></li><li><a href="Mouse.html">Mouse</a></li><li><a href="MouseDrag.html">MouseDrag</a></li><li><a href="Touch.html">Touch</a></li></ul></li><li class="category">Misc<ul class="category-list"><li><a href="Crafty-addEvent.html">Crafty.addEvent()</a></li><li><a href="Crafty-device.html">Crafty.device</a></li><li><a href="Crafty-removeEvent.html">Crafty.removeEvent()</a></li><li><a href="Crafty-support.html">Crafty.support</a></li></ul></li><li class="category">Model<ul class="category-list"><li><a href="Model.html">Model</a></li></ul></li><li class="category">Scenes<ul class="category-list"><li><a href="Crafty-scene.html">Crafty.scene()</a></li></ul></li><li class="category">Stage<ul class="category-list"><li><a href="Crafty-background.html">Crafty.background()</a></li><li><a href="Crafty-scene.html">Crafty.scene()</a></li><li><a href="Crafty-viewport.html">Crafty.viewport</a></li></ul></li><li class="category">Utilities<ul class="category-list"><li><a href="Crafty-math.html">Crafty.math</a></li><li><a href="Delay.html">Delay</a></li><li><a href="Storage.html">Storage</a></li></ul></li></ul></div><div id="doc-content" class="doc-page-holder"><div class="doc-page"><h1>Crafty.math.Matrix2D <span class="page-badge">Class</span></h1><div class="doclet" id="Crafty-math-Matrix2D"><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L749-L772">src/spatial/math.js#L749-L772</a></div><span class="markdown"><p>Matrix2D uses the following form, as per the whatwg.org specifications for canvas.transform():
[a, c, e]
[b, d, f]
[0, 0, 1]</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-qualifier">new </span><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code></div><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-qualifier">new </span><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code></div><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-qualifier">new </span><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Matrix2D|Number=1} a </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number=0} b </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number=0} c </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number=1} d </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number=0} e </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number=0} f </dt><dd><span class="markdown"></span></dd></dl></div></div><div><h4>Methods</h4><ul class="page-toc"><li><a href="#-apply">.apply()</a></li><li><a href="#-clone">.clone()</a></li><li><a href="#-combine">.combine()</a></li><li><a href="#-determinant">.determinant()</a></li><li><a href="#-equals">.equals()</a></li><li><a href="#-invert">.invert()</a></li><li><a href="#-isIdentity">.isIdentity()</a></li><li><a href="#-isInvertible">.isInvertible()</a></li><li><a href="#-preRotate">.preRotate()</a></li><li><a href="#-preScale">.preScale()</a></li><li><a href="#-preTranslate">.preTranslate()</a></li><li><a href="#-rotate">.rotate()</a></li><li><a href="#-scale">.scale()</a></li><li><a href="#-setValues">.setValues()</a></li><li><a href="#-toString">.toString()</a></li><li><a href="#-translate">.translate()</a></li></ul><div class="doclet" id="-apply"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.apply()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L799-L810">src/spatial/math.js#L799-L810</a></div><span class="markdown"><p>Applies the matrix transformations to the passed object</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Vector2D} </span><span class="sig-noun">apply</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Vector2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Vector2D} vecRH </dt><dd><span class="markdown"><p>vector to be transformed</p>
</span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Vector2D} the passed vector object after transforming</p>
</span></dd></dl></div></div><div class="doclet" id="-clone"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.clone()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L825-L835">src/spatial/math.js#L825-L835</a></div><span class="markdown"><p>Creates an exact, numeric copy of the current matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">clone</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D}</p>
</span></dd></dl></div></div><div class="doclet" id="-combine"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.combine()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L840-L852">src/spatial/math.js#L840-L852</a></div><span class="markdown"><p>Multiplies this matrix with another, overriding the values of this matrix.
The passed matrix is assumed to be on the right-hand side.</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">combine</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Matrix2D} mtrxRH </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix after combination</p>
</span></dd></dl></div></div><div class="doclet" id="-determinant"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.determinant()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L884-L894">src/spatial/math.js#L884-L894</a></div><span class="markdown"><p>Calculates the determinant of this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Number} </span><span class="sig-noun">determinant</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Number} det(this matrix)</p>
</span></dd></dl></div></div><div class="doclet" id="-equals"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.equals()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L866-L877">src/spatial/math.js#L866-L877</a></div><span class="markdown"><p>Checks for the numeric equality of this matrix versus another.</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Boolean} </span><span class="sig-noun">equals</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Matrix2D} mtrxRH </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Boolean} true if the two matrices are numerically equal</p>
</span></dd></dl></div></div><div class="doclet" id="-invert"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.invert()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L899-L910">src/spatial/math.js#L899-L910</a></div><span class="markdown"><p>Inverts this matrix if possible</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">invert</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this inverted matrix or the original matrix on failure</p>
</span></dd></dl></div><div><h4>See Also</h4><ul class="see-also-list"><li><a href="#-isInvertible">.isInvertible</a></li></ul></div></div><div class="doclet" id="-isIdentity"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.isIdentity()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L935-L945">src/spatial/math.js#L935-L945</a></div><span class="markdown"><p>Returns true if this matrix is the identity matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Boolean} </span><span class="sig-noun">isIdentity</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Boolean}</p>
</span></dd></dl></div></div><div class="doclet" id="-isInvertible"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.isInvertible()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L950-L961">src/spatial/math.js#L950-L961</a></div><span class="markdown"><p>Determines is this matrix is invertible.</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Boolean} </span><span class="sig-noun">isInvertible</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Boolean} true if this matrix is invertible</p>
</span></dd></dl></div><div><h4>See Also</h4><ul class="see-also-list"><li><a href="#-invert">.invert</a></li></ul></div></div><div class="doclet" id="-preRotate"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.preRotate()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L966-L977">src/spatial/math.js#L966-L977</a></div><span class="markdown"><p>Applies a counter-clockwise pre-rotation to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">preRotate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {number} rads </dt><dd><span class="markdown"><p>angle to rotate in radians</p>
</span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix after pre-rotation</p>
</span></dd></dl></div></div><div class="doclet" id="-preScale"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.preScale()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L992-L1004">src/spatial/math.js#L992-L1004</a></div><span class="markdown"><p>Applies a pre-scaling to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">preScale</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">[,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">])</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Number} scalarX </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} [scalarY] scalarX is used if scalarY is undefined </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this after pre-scaling</p>
</span></dd></dl></div></div><div class="doclet" id="-preTranslate"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.preTranslate()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1017-L1030">src/spatial/math.js#L1017-L1030</a></div><span class="markdown"><p>Applies a pre-translation to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">preTranslate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Vector2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code></div><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">preTranslate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Number|Vector2D} dx </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} dy </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix after pre-translation</p>
</span></dd></dl></div></div><div class="doclet" id="-rotate"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.rotate()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1043-L1054">src/spatial/math.js#L1043-L1054</a></div><span class="markdown"><p>Applies a counter-clockwise post-rotation to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">rotate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Number} rads </dt><dd><span class="markdown"><p>angle to rotate in radians</p>
</span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix after rotation</p>
</span></dd></dl></div></div><div class="doclet" id="-scale"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.scale()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1072-L1084">src/spatial/math.js#L1072-L1084</a></div><span class="markdown"><p>Applies a post-scaling to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">scale</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">[,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">])</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Number} scalarX </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} [scalarY] scalarX is used if scalarY is undefined </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this after post-scaling</p>
</span></dd></dl></div></div><div class="doclet" id="-setValues"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.setValues()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1099-L1116">src/spatial/math.js#L1099-L1116</a></div><span class="markdown"><p>Sets the values of this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">setValues</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Matrix2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code></div><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">setValues</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Matrix2D|Number} a </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} b </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} c </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} d </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} e </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} f </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix containing the new values</p>
</span></dd></dl></div></div><div class="doclet" id="-toString"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.toString()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1137-L1147">src/spatial/math.js#L1137-L1147</a></div><span class="markdown"><p>Returns the string representation of this matrix.</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{String} </span><span class="sig-noun">toString</span></span><span class="sig-seperator">()</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{String}</p>
</span></dd></dl></div></div><div class="doclet" id="-translate"><a href="#doc-nav" class="doc-top">Back to top</a><h2 class="doclet-header">.translate()</h2><div class="doc-source"><a href="https://github.com/craftyjs/Crafty/blob/1ef28454144100272fd439e5c3e8afb90601c00e/src/spatial/math.js#L1153-L1166">src/spatial/math.js#L1153-L1166</a></div><span class="markdown"><p>Applies a post-translation to this matrix</p>
</span><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">translate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Vector2D</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code></div><div class="crafty-method"><code class="signature"><span class="sig-phrase"><span class="sig-qualifier">public </span><span class="sig-qualifier">{Matrix2D} </span><span class="sig-noun">translate</span></span><span class="sig-seperator">(</span><span class="sig-phrase"><span class="sig-noun">Number</span></span><span class="sig-seperator">,</span><span class="sig-phrase"><span class="sig-qualifier"> </span><span class="sig-noun">Number</span></span><span class="sig-seperator">)</span><span class="sig-phrase"><span class="sig-noun">;</span></span></code><dl class="parameter"><dt> {Number|Vector2D} dx </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter"><dt> {Number} dy </dt><dd><span class="markdown"></span></dd></dl><dl class="parameter returns"><dt class="returns"> [Returns] </dt><dd><span class="markdown"><p>{Matrix2D} this matrix after post-translation</p>
</span></dd></dl></div></div></div></div></div></div>
			
		</div>
	</div>
	<div class="clearer"></div>
	<div id="footer">
		<div id="contact">
			<a href="https://groups.google.com/forum/#!forum/craftyjs">
				<img src="/images/google.png" />
				google groups</a>
			<a href="mailto:starwed@gmail.com">
				<img src="/images/email.png" />
				starwed@gmail.com</a>
			<a href="https://github.com/craftyjs/Crafty">
				<img src="/images/github.png" />
				github</a>
		</div>
		<ul>
			<li><a href="/">Home</a></li>
				<li><a href="/getting-started/">Getting started</a></li>
				<li><a href="/documentation/">Documentation</a></li>
				<li><a href="/api/">API</a></li>
				<li><a href="https://groups.google.com/forum/#!forum/craftyjs">Forum</a></li>
				<li><a href="/components/">Modules</a></li>
				<li class="emph"><a href="/#install">Download</a></li>
		</ul>
		<p>
			&copy; Crafty 2010-2015. Crafty is distributed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a>.
		</p>
	</div>
</div>
</body>
</html>
